﻿using System;
using System.ComponentModel;
using System.Reflection;
using System.Runtime.InteropServices;

namespace Teigha.Core
{
	public class OdEdPointTracker : OdEdInputTracker
	{
		[EditorBrowsable(EditorBrowsableState.Never)]
		public OdEdPointTracker(IntPtr cPtr, bool cMemoryOwn) : base(GlobalsPINVOKE.OdEdPointTracker_SWIGUpcast(cPtr), cMemoryOwn)
		{
			this.swigCPtr = new HandleRef(this, cPtr);
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static HandleRef getCPtr(OdEdPointTracker obj)
		{
			if (obj != null)
			{
				return obj.swigCPtr;
			}
			return new HandleRef(null, IntPtr.Zero);
		}

		~OdEdPointTracker()
		{
			this.Dispose();
		}

		public override void Dispose()
		{
			if (this.swigCPtr.Handle != IntPtr.Zero)
			{
				if (this.swigCMemOwn)
				{
					lock (this.locker)
					{
						if (this.swigCPtr.Handle != IntPtr.Zero && this.swigCMemOwn)
						{
							this.swigCMemOwn = false;
							GlobalsPINVOKE.delete_OdEdPointTracker(this.swigCPtr);
						}
					}
					this.swigCMemOwn = false;
				}
				this.swigCPtr = new HandleRef(null, IntPtr.Zero);
			}
			GC.SuppressFinalize(this);
			base.Dispose();
		}

		public OdEdPointTracker() : this(GlobalsPINVOKE.new_OdEdPointTracker(), MemoryManager.GetMemoryManager().GetCurrentTransaction() == null)
		{
			MemoryTransaction currentTransaction = MemoryManager.GetMemoryManager().GetCurrentTransaction();
			if (currentTransaction != null)
			{
				currentTransaction.AddObject(new OdEdPointTracker(this.swigCPtr.Handle, true));
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			this.SwigDirectorConnect();
		}

		public new static OdEdPointTracker cast(OdRxObject pObj)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdEdPointTracker_cast(OdRxObject.getCPtr(pObj));
			OdEdPointTracker result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdEdPointTracker)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdEdPointTracker)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdEdPointTracker)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new static OdRxClass desc()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdEdPointTracker_desc(), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxClass isA()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(this.SwigDerivedClassHasMethod("isA", OdEdPointTracker.swigMethodTypes1) ? GlobalsPINVOKE.OdEdPointTracker_isASwigExplicitOdEdPointTracker(this.swigCPtr) : GlobalsPINVOKE.OdEdPointTracker_isA(this.swigCPtr), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxObject queryX(OdRxClass protocolClass)
		{
			OdRxObject result = Teigha.Core.Helpers.odrxCreateObjectInternal(this.SwigDerivedClassHasMethod("queryX", OdEdPointTracker.swigMethodTypes0) ? GlobalsPINVOKE.OdEdPointTracker_queryXSwigExplicitOdEdPointTracker(this.swigCPtr, OdRxClass.getCPtr(protocolClass)) : GlobalsPINVOKE.OdEdPointTracker_queryX(this.swigCPtr, OdRxClass.getCPtr(protocolClass)), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new static OdEdPointTracker createObject()
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdEdPointTracker_createObject();
			OdEdPointTracker result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdEdPointTracker)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdEdPointTracker)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdEdPointTracker)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual void setValue(OdGePoint3d value)
		{
			GlobalsPINVOKE.OdEdPointTracker_setValue(this.swigCPtr, OdGePoint3d.getCPtr(value));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		private void SwigDirectorConnect()
		{
			if (this.SwigDerivedClassHasMethod("queryX", OdEdPointTracker.swigMethodTypes0))
			{
				this.swigDelegate0 = new OdEdPointTracker.SwigDelegateOdEdPointTracker_0(this.SwigDirectorqueryX);
			}
			if (this.SwigDerivedClassHasMethod("isA", OdEdPointTracker.swigMethodTypes1))
			{
				this.swigDelegate1 = new OdEdPointTracker.SwigDelegateOdEdPointTracker_1(this.SwigDirectorisA);
			}
			if (this.SwigDerivedClassHasMethod("addDrawables", OdEdPointTracker.swigMethodTypes2))
			{
				this.swigDelegate2 = new OdEdPointTracker.SwigDelegateOdEdPointTracker_2(this.SwigDirectoraddDrawables);
			}
			if (this.SwigDerivedClassHasMethod("removeDrawables", OdEdPointTracker.swigMethodTypes3))
			{
				this.swigDelegate3 = new OdEdPointTracker.SwigDelegateOdEdPointTracker_3(this.SwigDirectorremoveDrawables);
			}
			if (this.SwigDerivedClassHasMethod("setValue", OdEdPointTracker.swigMethodTypes4))
			{
				this.swigDelegate4 = new OdEdPointTracker.SwigDelegateOdEdPointTracker_4(this.SwigDirectorsetValue);
			}
			GlobalsPINVOKE.OdEdPointTracker_director_connect(this.swigCPtr, this.swigDelegate0, this.swigDelegate1, this.swigDelegate2, this.swigDelegate3, this.swigDelegate4);
		}

		private bool SwigDerivedClassHasMethod(string methodName, Type[] methodTypes)
		{
			MethodInfo method = base.GetType().GetMethod(methodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, methodTypes, null);
			return method.DeclaringType.IsSubclassOf(typeof(OdEdPointTracker));
		}

		private IntPtr SwigDirectorqueryX(IntPtr protocolClass)
		{
			return OdRxObject.getCPtr(this.queryX((OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(protocolClass, false))).Handle;
		}

		private IntPtr SwigDirectorisA()
		{
			return OdRxClass.getCPtr(this.isA()).Handle;
		}

		private int SwigDirectoraddDrawables(IntPtr pView)
		{
			return this.addDrawables((pView == IntPtr.Zero) ? null : new OdGsView(pView, false));
		}

		private void SwigDirectorremoveDrawables(IntPtr pView)
		{
			this.removeDrawables((pView == IntPtr.Zero) ? null : new OdGsView(pView, false));
		}

		private void SwigDirectorsetValue(IntPtr value)
		{
			this.setValue(new OdGePoint3d(value, false));
		}

		private object locker = new object();

		private HandleRef swigCPtr;

		private OdEdPointTracker.SwigDelegateOdEdPointTracker_0 swigDelegate0;

		private OdEdPointTracker.SwigDelegateOdEdPointTracker_1 swigDelegate1;

		private OdEdPointTracker.SwigDelegateOdEdPointTracker_2 swigDelegate2;

		private OdEdPointTracker.SwigDelegateOdEdPointTracker_3 swigDelegate3;

		private OdEdPointTracker.SwigDelegateOdEdPointTracker_4 swigDelegate4;

		private static Type[] swigMethodTypes0 = new Type[]
		{
			typeof(OdRxClass)
		};

		private static Type[] swigMethodTypes1 = new Type[0];

		private static Type[] swigMethodTypes2 = new Type[]
		{
			typeof(OdGsView)
		};

		private static Type[] swigMethodTypes3 = new Type[]
		{
			typeof(OdGsView)
		};

		private static Type[] swigMethodTypes4 = new Type[]
		{
			typeof(OdGePoint3d)
		};

		public delegate IntPtr SwigDelegateOdEdPointTracker_0(IntPtr protocolClass);

		public delegate IntPtr SwigDelegateOdEdPointTracker_1();

		public delegate int SwigDelegateOdEdPointTracker_2(IntPtr pView);

		public delegate void SwigDelegateOdEdPointTracker_3(IntPtr pView);

		public delegate void SwigDelegateOdEdPointTracker_4(IntPtr value);
	}
}
